package geradatawarehouse.dao.postgres;

import geradatawarehouse.dao.abs.AbstractDAO;
import geradatawarehouse.dao.postgres.abs.PostgresDAO;

import java.io.IOException;
import java.sql.SQLException;
import java.sql.Statement;

public class AlunoAuxTablesPostgresDAO extends PostgresDAO {

	private static final String PREENCHE_TABELAS_SECUNDARIAS_EJA_SQL = "preenche_tabelas_secundarias_eja.sql";
	private static final String PREENCHE_TABELAS_SECUNDARIAS_REGULAR_SQL = "preenche_tabelas_secundarias_regular.sql";
	private final boolean isEja;

	public AlunoAuxTablesPostgresDAO(final boolean isEja) throws IOException {
		this.isEja = isEja;
	}

	public void updateTables() throws IOException, SQLException {
		String query = null;
		query = AbstractDAO
				.loadQueryFile(this.isEja ? AlunoAuxTablesPostgresDAO.PREENCHE_TABELAS_SECUNDARIAS_EJA_SQL
						: AlunoAuxTablesPostgresDAO.PREENCHE_TABELAS_SECUNDARIAS_REGULAR_SQL);
		final Statement smt = this.buildStatement();
		smt.executeUpdate(query);
	}
}
